import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    home: MyHome(),
  ));
}

class MyHome extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.red,
          title: Text('案例-商品订单信息'),
        ),
        // ListView.builder 批量生成
        // ListView.separated 额外的设置分隔的内容
        body: GridView.builder(
          // 设置宽度
          // 要设置个数
          gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
              // 侧轴方向子元素的个数
              crossAxisCount: 2,
              mainAxisSpacing: 10,
              crossAxisSpacing: 30,
              childAspectRatio: 4 / 3),
          itemBuilder: (context, index) {
            return Container(
              color: Colors.green,
              alignment: Alignment.center,
              child: const Text('黑马程序员1'),
            );
          },
          itemCount: 3,
        ));
  }
}
